package com.ycp.erp.customer.ui.activity;

import android.annotation.SuppressLint;
import android.util.TimeUtils;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jakewharton.rxbinding2.view.RxView;
import com.one.common.config.RouterPath;
import com.one.common.manager.RouterManager;
import com.one.common.view.base.IListView;
import com.one.common.view.pagestate.listpage.BaseListActivity;
import com.one.common.view.widget.MyTitleBar;
import com.ycp.erp.R;
import com.ycp.erp.customer.ui.binder.CustomerManagerBinder;
import com.ycp.erp.supplier.model.bean.SupplierBean;
import com.ycp.erp.supplier.ui.binder.SupplierManagerBinder;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

/**
 * Class Des:客户管理
 * Created by bjh on 2021/9/1.
 */
@Route(path = RouterPath.CUSTOMER_MANAGER)
public class CustomerManagementActivity extends BaseListActivity implements IListView {
    private ArrayList<SupplierBean> supplierBeans;

    @Override
    protected void initPresenter() {

    }

    @Override
    public void registerDate() {
        CustomerManagerBinder binder = new CustomerManagerBinder();
        register(SupplierBean.class,binder);
    }
    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("客户管理").hideLine();
    }
    @SuppressLint("CheckResult")
    @Override
    public void initView() {
        super.initView();
        addTopView(R.layout.layout_search);
        addBottomView(R.layout.layout_submit_bottom);
        TextView tvSubmit = successView.findViewById(R.id.tvSubmit);
        tvSubmit.setText("添加客户");
        RxView.clicks(tvSubmit).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o->{
            RouterManager.getInstance().go(RouterPath.ADD_CUSTOMER);
        });
    }
    
    @Override
    public void loadData() {
       this.getAdapter().setItems(supplierBeans);
       getAdapter().notifyDataSetChanged();
    }

    @Override
    public void initData() {
        super.initData();
        initMNData();
        loadData();
    }

    /**
     * 模拟数据
     *
     * @return
     */
    private void initMNData() {
         supplierBeans = new ArrayList<>();
        SupplierBean supplierBean = new SupplierBean();
        supplierBean.setName("测试");
        supplierBean.setPhone("18995995959");
        supplierBeans.add(supplierBean);
        SupplierBean supplierBean1 = new SupplierBean();
        supplierBean1.setName("张三");
        supplierBean1.setPhone("18995995959");
        supplierBeans.add(supplierBean1);
        SupplierBean supplierBean2 = new SupplierBean();
        supplierBean2.setName("李四");
        supplierBean2.setPhone("18995995959");
        supplierBeans.add(supplierBean2);
        SupplierBean supplierBean3 = new SupplierBean();
        supplierBean3.setName("李三四");
        supplierBean3.setPhone("18995995959");
        supplierBeans.add(supplierBean3);
        SupplierBean supplierBean4 = new SupplierBean();
        supplierBean4.setName("王五");
        supplierBean4.setPhone("18995995959");
        supplierBeans.add(supplierBean4);
    }
}
